import { appTypeMin } from "../enum/appType.enum"
import { phaseMin } from "../enum/phase.enum"
import Data from "../object/Data"
import ObservableProxy from "../observer/observable.proxy"

export default class ApplicationData extends Data {
  phase: number
  application: string
  phaseTimes: Record<number, number>
  error: any
  constructor(e: number, t = appTypeMin.UNKNOWN) {
    super()
    this.name = "app"
    this.phase = e
    this.application = t
    this.phaseTimes = ObservableProxy({
      [phaseMin.UNINITIALIZED]: 0,
      [phaseMin.WAITING]: 0,
      [phaseMin.LOADING]: 0,
      [phaseMin.STARTING]: 0,
      [phaseMin.PLAYING]: 0,
      [phaseMin.ERROR]: 0
    })
    this.error = null
  }
  getName() {
    return this.application.toString()
  }
  getVersion() {
    return "3.1"
  }
}
export const createApplicationData = () => new ApplicationData(phaseMin.UNINITIALIZED)
